//
//  NetworkPermissionManager.swift
//  网络状态监听
//
//  Created by mini on 2025/4/28.
//

import Foundation
import Network

class NetworkPermissionManager {
    static func requestNetworkPermission() {
        // 创建一个网络监听器
        let monitor = NWPathMonitor()
        
        // 设置监听回调
        monitor.pathUpdateHandler = { path in
            if path.status == .satisfied {
                print("网络连接正常")
            } else {
                print("无网络连接")
            }
            
            // 使用完后停止监听
            monitor.cancel()
        }
        
        // 开始监听，这会触发系统权限弹窗
        let queue = DispatchQueue(label: "NetworkPermission")
        monitor.start(queue: queue)
    }
}
